package demo2;

import java.util.Arrays;

public class Test {
    public static void main(String[] args) {
        test1();
        test2();
    }
    public static void test2() {
        int[] nums = {1,1,2,2,3,4};
        int slow = 0;
        for(int fast = 1;fast < nums.length; fast++) {
            if(nums[fast] != nums[slow]) {
                slow++;
                nums[slow] = nums[fast];
            }
        }
        System.out.println(Arrays.toString(nums));
    }

    public static void test1() {
        int[] nums1 = {1,2,3,0,0,0};
        int m = 3;
        int[] nums2 = {2,5,6};
        int n = 3;
        int[] temp = new int[m+n];
        temp = Arrays.copyOf(nums1,m+n);
        System.arraycopy(nums2,0,temp,m,n);
        Arrays.sort(temp);
        System.out.println(Arrays.toString(temp));
    }
}
